package com.kiteqi.wxorder.service.impl;

import com.kiteqi.wxorder.entity.ProductCategory;
import com.kiteqi.wxorder.mapper.CategoryMapper;
import com.kiteqi.wxorder.service.CategoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class CategoryServiceImpl implements CategoryService {

    @Autowired
    private CategoryMapper categoryMapper;

    @Override
    public ProductCategory findOne(Integer categoryId) {
        ProductCategory category = this.categoryMapper.selectById(categoryId);
        return category;
    }

    @Override
    public List<ProductCategory> findAll() {
        return this.categoryMapper.selectList(null);
    }

    @Override
    public int save(ProductCategory category) {
        return this.categoryMapper.insert(category);
    }

    @Override
    public int update(ProductCategory category) {
        return this.categoryMapper.updateById(category);
    }
}
